Deep Thought has beaten mankind as the game once thought to exemplify human intuition. Our MacHack laboratory is secretly constructing an implant that will neutralize the calculation advantage held by the computer, and restore mankind to its rightful place as the champion of chess, through intuition and cunning. Your job is to write the code that will calculate the board position resulting from a sequence of moves, along with the legal moves available to the next player. With this advantage, the human chess master will be able to concentrate on strategy, rather than waste time calculating moves.
UInt16 row; /* 0..7, white initially occupies rows 0 and 1, black 7 and 6 */
UInt16 col; /* 0..7, white king starts at (row,col) == (0,4) */
} Square;
typedef struct ChessMove {
Square fromSquare;
Square toSquare;
Boolean capture;
Square capturedSquare; /* valid only if capture==TRUE */
} ChessMove;
typedef struct ChessPiece {
PieceColor whichColor;
PieceRank whichRank;
Square pieceLocation;
} ChessPiece;
pascal void FindLegalChessMoves(
UInt32 numPriorMoves,
ChessMove priorMoves[],
UInt32 *numPiecesRemaining,
ChessPiece piecesRemaining[],
UInt32 *numLegalMoves,
ChessMove legalMoves[]
);
Your FindLegalChessMoves routine will be called with a list (priorMoves) of numPriorMoves that have already taken place from the normal initial chessboard. You should model the effects of those moves and generate a list (piecesRemaining) of the numPiecesRemaining pieces remaining, including their location on the board, and a list (legalMoves) of all numLegalMoves legal moves available to the next player. Remember to include castling moves when appropriate (indicated by moving the king the appropriate two/three squares) and en passant pawn captures.
#endif
#include "Solution.h"
// Fill in your solution and then submit this folder